<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>更新购物车</title>
</head>
<body>
<div id="app">
    {{ prices }}
</div>

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script type="text/javascript">
    var app = new Vue({
        el: "#app",
        data: {
            package1: [{
                name: "huawei mate20",
                price: 10000,
                count: 10,
            }, {
                name: "honor 30",
                price: 999,
                count: 10,
            }, {
                name: "xiaomi 10",
                price: 888,
                count: 15,
            }],
            package2: [{
                name: "meizu 16",
                price: 2000,
                count: 5,
            }, {
                name: "vivo 10",
                price: 2500,
                count: 10,
            }, {
                name: "oppo 20",
                price: 3000,
                count: 10,
            }]
        },
        computed: {
            prices: function () {
                var prices = 0;
                for (var i = 0; i < this.package1.length; i++) {
                    prices += this.package1[i].price * this.package1[i].count;
                }
                for (var i = 0; i < this.package2.length; i++) {
                    prices += this.package2[i].price * this.package2[i].count;
                }
                return prices;
            }
        }
    })
</script>
</body>
</html>